package com.base.cn.platform.os.controller.course.cou.live;

import com.base.cn.platform.os.common.AdminBaseController;
import com.base.cn.platform.os.common.utils.course.CourseType;
import com.base.cn.platform.os.service.course.cou.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * 直播Controller
 *
 * @author s.li
 * @date 2018/10/23
 */
@Controller
@RequestMapping("/admin/course/live")
public class AdminLiveCourseController extends AdminBaseController {
    @Autowired
    private CourseService courseService;

    @RequestMapping("/liveList")
    public String liveList(){
        return resultPage("/course/cou/live/live_course_list");
    }

    /**
     * 获取课程数据
     * @param params
     * @param currentPage 当前页码
     * @return 列表页面
     */
    @RequestMapping("/ajaxLiveCourseList")
    public String ajaxCourseList(Model model,
                                 @RequestBody Map<String,Object> params,
                                 @RequestParam(value = "currentPage",required = false,defaultValue = "1") int currentPage){
        params.put("courseTypeKey", CourseType.COURSE_TYPE_LIVE.getKey());
        params.put("type",1);
        Map<String,Object> dataMap = courseService.findCoursePage(params,currentPage,12,false,true,true);
        model.addAttribute("dataMap",dataMap);
        return resultPage("/course/cou/live/ajax_live_course_list");
    }
}
